<template>
  <div>
    <h2>响应式数据和计算属性</h2>
    <input type="number" v-model="num1" />
    <input type="number" v-model="num2" />
    <button @click="sumon">等于</button>
    <p v-if="sum">{{ sum }}</p>
  </div>
</template>

<script setup lang="ts">
import { computed, ref } from 'vue'

const num1 = ref(0)
const num2 = ref(0)
const sum = ref()
const sumon = () => {
  sum.value = computed(() => {
    return num1.value + num2.value
  })
}
</script>

<style></style>
